﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using IDAL;
using Model;

namespace DAL
{
    public class D_UserVip : IUserVip
    {
        WishDayEntities _e;
        public D_UserVip()
        {
            _e = new WishDayEntities();
        }
        public void Add(UserVip obj)
        {
            _e.UserVip.Add(obj);
            _e.SaveChanges();
        }

        public void Delete(int id)
        {
            var data = _e.UserVip.Find(id);

            _e.UserVip.Remove(data);
            _e.SaveChanges();

        }

        public UserVip FindById(int id)
        {
            return _e.UserVip.Find(id);
        }

        public List<UserVip> GetAll()
        {
            return _e.UserVip.ToList();
        }

        public void Update(int id, UserVip obj)
        {
            var data = _e.UserVip.Find(id);
            data.VInTime = obj.VInTime;
            data.VOutTime = obj.VOutTime;
            data.LevelID = obj.LevelID;
            _e.SaveChanges();
        }
    }
}
